<extend name="Common/backend_base" />

<block name="content">
    <div class="location" data-toggle="modal" data-target="#locationModal">
        <empty name="Think.session.location">
            <span>地区选择</span>
            <else />
            <span>{$Think.session.location}</span>
        </empty>
        <i class="icon-map"></i>
    </div>

    <!-- 模态框（Modal） -->
    <div class="modal fade" id="locationModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        地区选择
                    </h4>
                </div>
                <div class="modal-body">
                    <ul class="list-group">
                        <li class="list-group-item">全国</li>
                        <li class="list-group-item">北京通州</li>
                        <li class="list-group-item">内蒙古鄂尔多斯</li>
                        <li class="list-group-item">江苏常州</li>
                    </ul>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 内容 -->
    <notempty name="Think.session.location">
        <if condition="$Think.session.location neq '全国'">
            <iframe src="http://123.57.22.77/dcim/main_index?sso=1&sessionKey={:session('sso_session_key')}" width="100%" height="100%" frameborder="0"></iframe>
        <else/>
            <div id="header-local">
                <h1></h1>
                <div class="header-nav">
                    <ul>
                        <li>
                            <a href="#">
                                <i class="icon-home"></i>
                                <span>报表管理</span>
                            </a>
                        </li>
                        <li>
                            <a href="{:U('/user/list')}">
                                <i class="icon-home"></i>
                                <span>用户管理</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </if>
    </notempty>
    <!-- 内容 -->
</block>
<block name="script">
    <script type="application/javascript">
        requirejs(['jquery'], function ($) {
            $('.list-group-item').each(function () {
                var _this = $(this);

                _this.click(function () {
                    $('#locationModal').modal('hide');

                    var place = $(this).html();
                    $('.location').find('span').html(place);

                    $.ajax({
                        url: 'home/selectLocation',
                        type: 'POST',
                        data: {
                            'location': place
                        },
                        success: function () {
                            location.reload();
                        }
                    })
                });
            });
        });
    </script>
</block>